﻿<?php
/**
 * DESCRIPTION:
 *  functions to convert strings to something beautiful)))
 * METHODS:
 *  string transliterate(String $st) transliterates cyrillic to latin
 * ======
 * @author at8eqeq3
 * @version 0.1
 */

function transliterate($st){ //TODO make this work with Unicode!!!
    //change the rules, if needed
    $st = strtr($st, 'абвгдезийклмнопрстувхъыьэАБВГДЕЗИЙКЛМНОПРСТУФХЪЫЬЭ',
                     'abvgdezijklmnoprstufh_y_eABVGDEZIJKLMNOPRSTUFH_Y_E');
    $st = strtr($st, array('ё' => 'yo',
                           'ж' => 'zh',
                           'ц' => 'ts',
                           'ч' => 'ch',
                           'ш' => 'sh',
                           'щ' => 'sch',
                           'ю' => 'yu',
                           'я' => 'ya',
                           'Ё' => 'YO',
                           'Ж' => 'ZH',
                           'Ц' => 'TS',
                           'Ч' => 'CH',
                           'Ш' => 'SH',
                           'Щ' => 'SCH',
                           'Ю' => 'YU',
                           'Я' => 'YA'));
    return $st;
}

function walkarray($arr, $counter=1){
    foreach($arr as $k => $v){
        for($i=0; $i<$counter; $i++){
            $s .= '+-';
        }
        $s .= "$k => $v\n";
        if(is_array($v)){
            $s .= walkarray($v, $counter++);
        }
    }
    return $s;
}

//no way to use this script apart from app
global $up_and_running;
if(!isset($up_and_running) || $up_and_running == false){
    echo 'from '.__FILE__.':<br />';
    echo '<b><font size="7">TITS OR GTFO!!!</font></b>'; //better to change this string ;)
}
?>